﻿using System;
using System.Windows.Forms;

namespace ClientApp
{
    public partial class AddSimpleEntityForm : Form
    {
        private AdminForm _parent ;
        public AddSimpleEntityForm(AdminForm parent, string header)
        {
            _parent = parent;

            InitializeComponent();

            Text = header;
        }

        private void AddButton_Click(object sender, EventArgs e)
        {
            if (TitleTextBox.Text == "" || DescriptionRichTextBox.Text == "")
            {
                MessageBox.Show("Заполните все поля.", "Ошибка");
                return;
            }

            _parent.NewSimpleEntityTitle = TitleTextBox.Text;
            _parent.NewSimpleEntityDescripition = DescriptionRichTextBox.Text;

            Close();
        }

        private void AddSimpleEntityForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            _parent.Enabled = true;
            _parent.UpdateDataListBox();
        }

        private void AddSimpleEntityForm_Activated(object sender, EventArgs e)
        {
            _parent.Enabled = false;
        }
    }
}
